package com.ld.control.business.equipment.controller;


import com.ld.control.business.equipment.service.EquipmentMethodParamTmpService;
import com.ld.control.business.equipment.vo.req.EquipmentMethodParamTmpReqVo;
import com.ld.control.business.equipment.vo.resp.EquipmentMethodParamTmpRespVo;
import com.ld.control.common.vo.GenerateListVo;
import com.ld.control.common.ResultResponse;
import com.ld.control.sysenum.ResultResponseEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 设备表 前端控制器
 * </p>
 *
 * @author wangfeng
 * @since 2024-04-17
 */
@Slf4j
@Tag(name = "设备方法参数模板相关接口")
@RestController
public class EquipmentMethodParamTmpController {

    @Autowired
    private EquipmentMethodParamTmpService equipmentMethodParamTmpService;

    @GetMapping("/api/centralControl/equipmentMethodParamTmp/getList")
    @Operation(summary = "设备方法参数模板列表")
    public ResultResponse<GenerateListVo<EquipmentMethodParamTmpRespVo>> getList(
            @Parameter(description = "设备方法模板id") @RequestParam Long equipmentMethodTmpId
    ){
        List<EquipmentMethodParamTmpRespVo> equipmentMethodTmpRespVoList = equipmentMethodParamTmpService.getList(equipmentMethodTmpId);
        return ResultResponse.success(new GenerateListVo<>(equipmentMethodTmpRespVoList));
    }

    @GetMapping("/api/centralControl/equipmentMethodParamTmp/getMethodDebugParamList")
    @Operation(summary = "方法调试参数列表")
    public ResultResponse<GenerateListVo<EquipmentMethodParamTmpRespVo>> getMethodDebugParamList(
            @Parameter(description = "设备方法模板id") @RequestParam Long equipmentMethodTmpId
    ){
        List<EquipmentMethodParamTmpRespVo> equipmentMethodTmpRespVoList = equipmentMethodParamTmpService.getMethodDebugParamList(equipmentMethodTmpId);
        return ResultResponse.success(new GenerateListVo<>(equipmentMethodTmpRespVoList));
    }

    @PostMapping("/api/centralControl/equipmentMethodParamTmp/add")
    @Operation(summary = "新增设备方法参数模板")
    public ResultResponse<ResultResponseEnum> add(
            @RequestBody EquipmentMethodParamTmpReqVo reqVo
    ){
        equipmentMethodParamTmpService.add(reqVo);
        return ResultResponse.success();
    }

    @PostMapping("/api/centralControl/equipmentMethodParamTmp/update")
    @Operation(summary = "修改设备方法参数模板")
    public ResultResponse<ResultResponseEnum> update(
            @RequestBody EquipmentMethodParamTmpReqVo reqVo
    ){
        equipmentMethodParamTmpService.update(reqVo);
        return ResultResponse.success();
    }

    @PostMapping("/api/centralControl/equipmentMethodParamTmp/deleteById")
    @Operation(summary = "删除设备方法参数模板")
    public ResultResponse<ResultResponseEnum> deleteById(
            @Parameter(description = "参数主键id") @RequestParam Long id
    ){
        equipmentMethodParamTmpService.deleteById(id);
        return ResultResponse.success();
    }

}

